<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/17
 * Time: 11:28
 */

namespace app\index\controller;


use think\Controller;
use think\Db;
use think\Exception;

class Addtype extends Controller
{
    public function start(){
        self::insert_bag();
        self::insert_clothing();
        self::insert_jewelry();
        self::insert_shoe();
    }

    /**
     * @Notes:首饰类添加
     * @author: LiBaoJin
     * @Time:
     */
    public function  insert_jewelry(){
      $data = Db::table('systematics')
          ->where(['superior_id'=>3,'type'=>2])
          ->select();

      $list = [];
      foreach($data as $k=>$v){
          $list[$k]=[
              'superior_id'=>$v['id'],
              'superior_gene'=>'3-'.$v['id'],
              'type'=>3,
              'state'=>0,
              'title'=>'CHAUMET/尚美巴黎',
              'createtime'=>date('Y-m-d H:i:s',time()),
              'system_id'=>1,
              'label'=>'C'
          ];
      }
      try{
          $insert_jewelry = Db::table('systematics')
            ->insertAll($list);
         var_dump(['insert_jewelry'=>$insert_jewelry]);
      }catch(Exception$e){
        var_dump($e->getMessage());
      }
  }
    /**
     *包类添加
     */
    public function  insert_bag(){
        $data = Db::table('systematics')
            ->where(['superior_id'=>1,'type'=>2])
            ->select();
        $title = ['GOYARD/高雅德','Moynat/莫奈','MK/MICHAEL KORS/迈克科尔斯','Sophie Hulme/索菲.休姆','COACH/蔻驰'];

        $list = [];
foreach($title as $key=>$ti){
        $firstword = substr($ti,0,1);
        foreach($data as $k=>$v){
            $list[$k][]=[
                'superior_id'=>$v['id'],
                'superior_gene'=>'1-'.$v['id'],
                'type'=>3,
                'state'=>0,
                'title'=>$ti,
                'createtime'=>date('Y-m-d H:i:s',time()),
                'system_id'=>1,
                'label'=>$firstword
            ];
        }

}
        try{
            $inser_Data = [];
            foreach($list as $lis){
                $inser_Data[] = Db::table('systematics')
                    ->insertAll($lis);
            }

            var_dump(['insert_bag'=>$inser_Data]);
        }catch(Exception$e){
           var_dump($e->getMessage());
        }
    }
    /**
     * @Notes:鞋子类添加
     * @author: LiBaoJin
     * @Time:
     */
    public function  insert_shoe(){
        $title = [
          'Giuseppe Zanotti/朱塞佩..萨诺第',
            'Manolo Blahnik/马诺洛',
            'RV/ROGER  VIVIER/罗杰.维维亚',
            'RO/Rick Owens/瑞克.欧文斯',
            'RENE Caovilla/RC/芮妮.乔薇拉',
            'Stuart Weitzman /SW/斯图尔特.韦茨曼'
        ];
        $list = [];
        foreach($title as $key=>$ti){
            $firstword = substr($ti,0,1);
                $list[$key]=[
                    'superior_id'=>'41',
                    'superior_gene'=>'4-41',
                    'type'=>3,
                    'state'=>0,
                    'title'=>$ti,
                    'createtime'=>date('Y-m-d H:i:s',time()),
                    'system_id'=>1,
                    'label'=>$firstword,
                ];
            }
        try{
                $inser_Data = Db::table('systematics')
                    ->insertAll($list);

            var_dump(['insert_shoe'=>$inser_Data]);
        }catch(Exception$e){
            var_dump($e->getMessage());
        }
    }
    /**
     * @Notes:衣服配置类添加
     * @author: LiBaoJin
     * @Time:
     */
    public function insert_clothing(){
       try{
        $insert_clothing = Db::table('systematics')
            ->insertGetId([
                'superior_id'=>'4',
                'superior_gene'=>'4',
                'type'=>2,
                'state'=>0,
                'title'=>'衣服配饰',
                'createtime'=>date('Y-m-d H:i:s',time()),
                'system_id'=>1,
                'label'=>'Y',
                'picture'=>'http://resource.growthupup.com/91bcb13339e08f2fdc59135709571fc3.jpg'

            ]);
          $Data =  Db::table('systematics')
              ->insertGetId([
                  'superior_id'=>$insert_clothing,
                  'superior_gene'=>'4-'.$insert_clothing,
                  'type'=>3,
                  'state'=>0,
                  'title'=>'MONCLER/蒙口',
                  'createtime'=>date('Y-m-d H:i:s',time()),
                  'system_id'=>1,
                  'label'=>'M',

              ]);
            var_dump($Data);
       }catch(Exception$e){
           var_dump($e->getMessage());
       }

    }
    /**
     * @Notes:宝格丽系列
     * @author: LiBaoJin
     * @Time:
     */
    public function select_list(){
        $data = Db::table('systematics')
                ->where(['title'=>['like','bvlgari%'],'type'=>3])
            ->select();
        $title = ['SERPENTI系列','SPRING CAPSULE COLLECTION系列','BVLGARI BVLGARI系列',
            'VEVNING&COCKTALL系列','BVLGARI BALGARI MAN系列','DIVAS’DREAM系列'];
        $list = [];
        foreach($title as $key=>$ti){
            $firstword = substr($ti,0,1);
            foreach($data as $k=>$v){
                $list[$k][]=[
                    'superior_id'=>$v['id'],
                    'superior_gene'=>$v['superior_gene'].'-'.$v['id'],
                    'type'=>4,
                    'state'=>0,
                    'title'=>$ti,
                    'createtime'=>date('Y-m-d H:i:s',time()),
                    'system_id'=>1,
                    'label'=>$firstword
                ];
            }

        }
        try{
            $inser_Data = [];
            foreach($list as $lis){
                $inser_Data[] = Db::table('systematics')
                    ->insertAll($lis);
            }

            var_dump(['select_list'=>$inser_Data]);
            echo "<br>";
        }catch(Exception$e){
            var_dump($e->getMessage());
        }

    }

   public function add_server(){
       self::chanel_add();
       self::loewe_add();
       self::prada_add();
       self::salvatore_add();
       self::Louis_add();
       self::Yves_add();
   }
    /**
     * @Notes:香奈儿系列
     * @author: LiBaoJin
     * @Time:
     */
    public function chanel_add(){
        $data = Db::table('systematics')
            ->where(['title'=>['like','chanel%'],'type'=>3])
            ->select();
        $title = ['GABRIELLE/流浪包系列','方胖子系列'];
        $list = [];
        foreach($title as $key=>$ti){
            if($key==0){
                $firstword = substr($ti,0,1) ;
            }else{
                $firstword = 'F';
            }
            foreach($data as $k=>$v){
                $list[$k][]=[
                    'superior_id'=>$v['id'],
                    'superior_gene'=>$v['superior_gene'].'-'.$v['id'],
                    'type'=>4,
                    'state'=>0,
                    'title'=>$ti,
                    'createtime'=>date('Y-m-d H:i:s',time()),
                    'system_id'=>1,
                    'label'=>$firstword
                ];
            }

        }
        try{
            $inser_Data = [];
            foreach($list as $lis){
                $inser_Data[] = Db::table('systematics')
                    ->insertAll($lis);
            }

            var_dump(['chanel_add'=>$inser_Data]);
            echo "<br>";
        }catch(Exception$e){
            var_dump($e->getMessage());
        }
    }
    /**
     * @Notes:罗意威
     * @author: LiBaoJin
     * @Time:
     */
    public  function  loewe_add(){
        $data = Db::table('systematics')
            ->where(['title'=>['like','loewe%'],'type'=>3])
            ->select();
        $title = ['托特包系列','Puzzle系列','GATE系列','HAMMOCK系列','Barclona系列'];
        $list = [];
        foreach($title as $key=>$ti){
            if($key==0){
                $firstword = 'T';
            }else{
                $firstword = substr($ti,0,1) ;
            }
            foreach($data as $k=>$v){
                $list[$k][]=[
                    'superior_id'=>$v['id'],
                    'superior_gene'=>$v['superior_gene'].'-'.$v['id'],
                    'type'=>4,
                    'state'=>0,
                    'title'=>$ti,
                    'createtime'=>date('Y-m-d H:i:s',time()),
                    'system_id'=>1,
                    'label'=>$firstword
                ];
            }

        }
        try{
            $inser_Data = [];
            foreach($list as $lis){
                $inser_Data[] = Db::table('systematics')
                    ->insertAll($lis);
            }

            var_dump(['loewe_add'=>$inser_Data]);
            echo "<br>";
        }catch(Exception$e){
            var_dump($e->getMessage());
        }
    }
    /**
     * @Notes:普拉达
     * @author: LiBaoJin
     * @Time:
     */
    public function prada_add(){
        $data = Db::table('systematics')
            ->where(['title'=>['like','prada%'],'type'=>3])
            ->select();
        $title = ['降落伞尼龙背包系列','GALLERIA杀手包系列','CAHIER(盒子)系列','DOUBLE系列','Monochrome系列'];
        $list = [];
        foreach($title as $key=>$ti){
            if($key==0){
                $firstword = 'J';
            }else{
                $firstword = substr($ti,0,1) ;
            }
            foreach($data as $k=>$v){
                $list[$k][]=[
                    'superior_id'=>$v['id'],
                    'superior_gene'=>$v['superior_gene'].'-'.$v['id'],
                    'type'=>4,
                    'state'=>0,
                    'title'=>$ti,
                    'createtime'=>date('Y-m-d H:i:s',time()),
                    'system_id'=>1,
                    'label'=>$firstword
                ];
            }

        }

        try{
            $inser_Data = [];
            foreach($list as $lis){
                $inser_Data[] = Db::table('systematics')
                    ->insertAll($lis);
            }

            var_dump(['prada_add'=>$inser_Data]);
            echo "<br>";
        }catch(Exception$e){
            var_dump($e->getMessage());
        }
    }
    /**
     * @Notes:菲拉格慕
     * @author: LiBaoJin
     * @Time:
     */
    public function salvatore_add(){
        $data = Db::table('systematics')
            ->where(['title'=>['like','Salvatore Ferragamo%'],'type'=>3])
            ->select();
                $title = 'VARA蝴蝶结';
                $list = [];
                $firstword = substr($title,0,1) ;
            foreach($data as $k=>$v){
                $list[$k]=[
                    'superior_id'=>$v['id'],
                    'superior_gene'=>$v['superior_gene'].'-'.$v['id'],
                    'type'=>4,
                    'state'=>0,
                    'title'=>$title,
                    'createtime'=>date('Y-m-d H:i:s',time()),
                    'system_id'=>1,
                    'label'=>$firstword
                ];
        }

        try{
                $inser_Data = Db::table('systematics')
                    ->insertAll($list);
            var_dump(['salvatore_add'=>$inser_Data]);
            echo "<br>";
        }catch(Exception$e){
            var_dump($e->getMessage());
        }
    }
    //Louis Vuitton/LV/路易·威登
    public function Louis_add(){
        $data = Db::table('systematics')
            ->where(['title'=>['like','Louis Vuitton%'],'type'=>3])
            ->select();
        $title = ['NOE系列','LOUIS VUITTON NEW WAVE系列','SURENE系列','VICTOIRE系列','TRUNK CLUTCH (软盒子)系列',
        'CITY STEAMER','GEORGES ','SAINTONGE (相机包)','MARIGNAN(锁头邮差包)','BRITTANY','MYLOCKNE  (信封包)',
        'TUILERIES','PALLAS (传奇)','ARTSY','DUFFLE (薯条包)','CITY MALLE(走秀款拼色)','CHANTILLY  LOCK (马鞍包)',
        'SQUARE (筛子包)','PETITE BOITE CHAPEAU(圆饼)','CANNES  (圆筒包)','BOITE CHAPEAU (软圆饼)'];

        $list = [];
        foreach($title as $key=>$ti){
                $firstword = substr($ti,0,1) ;
            foreach($data as $k=>$v){
                $list[$k][]=[
                    'superior_id'=>$v['id'],
                    'superior_gene'=>$v['superior_gene'].'-'.$v['id'],
                    'type'=>4,
                    'state'=>0,
                    'title'=>$ti,
                    'createtime'=>date('Y-m-d H:i:s',time()),
                    'system_id'=>1,
                    'label'=>$firstword
                ];
            }

        }
        try{
            $inser_Data = [];
            foreach($list as $lis){
                $inser_Data[] = Db::table('systematics')
                    ->insertAll($lis);
            }

            var_dump(['Louis_add'=>$inser_Data]);
            echo "<br>";
        }catch(Exception$e){
            var_dump($e->getMessage());
        }
    }
 //Yves Saint Laurent/YSL/圣罗兰
     public function Yves_add(){
         $data = Db::table('systematics')
             ->where(['title'=>['like','Yves Saint Laurent%'],'type'=>3])
             ->select();
         $title = ['niki','vicky小包','lou流苏全皮小包','KATE (YSL扣流苏链条包)','Loulou(Y形链条包)',
            'SUNSET(王子文同款)','SAC DE JOUR(风琴包)'];
         $list = [];
         foreach($title as $key=>$ti){
             $firstword = substr($ti,0,1) ;
             foreach($data as $k=>$v){
                 $list[$k][]=[
                     'superior_id'=>$v['id'],
                     'superior_gene'=>$v['superior_gene'].'-'.$v['id'],
                     'type'=>4,
                     'state'=>0,
                     'title'=>$ti,
                     'createtime'=>date('Y-m-d H:i:s',time()),
                     'system_id'=>1,
                     'label'=>$firstword
                 ];
             }

         }

         try{
             $inser_Data = [];
             foreach($list as $lis){
                 $inser_Data[] = Db::table('systematics')
                     ->insertAll($lis);
             }

             var_dump(['Yves_add'=>$inser_Data]);
             echo "<br>";
         }catch(Exception$e){
             var_dump($e->getMessage());
         }
     }



public function yifu_up(){
    self::insert_yifu();
    self::delect_gst();
    self::delect_piazza();
}
    public function  insert_yifu(){
        $title = [
            "巴利/Bally8年",
            "Phillip Lim/菲利林",
            "Agnes b",
            "Alaia",
            "Alexander McQueen/亚历山大·麦昆",
            "Alexander Wang/亚历山大·王",
            "anteprima",
            "Balenciaga/巴黎世家",
            "Balmain/巴尔曼",
            "Bottege Veneta/BV/葆蝶家",
            "Burberry/博柏利",
            "BVLGARI/宝格丽",
            "Cartier/卡地亚",
            "Chanel/香奈儿",
            "CHLOE/蔻依",
            "Christian Dior/克里斯汀·迪奥",
            "Comtesse",
            "Celine/思琳",
            "Dolce&Gabbana/杜嘉班纳",
            "Delvaux/德尔沃",
            "Designer",
            "Dries Van Noten/德赖斯·范诺顿",
            "Dunhill/登喜路",
            "Tiffany & Co爱思卡达/ESCADA/蒂芙尼",
            "ETRO/艾特罗",
            "Fendi/芬迪",
            "Van Cleef & Arpels/VCA/梵克雅宝",
            "Furla/芙拉",
            "Givenchy/纪梵希",
            "Gucci/古驰",
            "Hermès/爱马仕",
            "HUGO BOSS/雨果博斯",
            "Issey Miyake/三宅一生",
            "Jean-Paul Gaultier/高缇耶",
            "JIL SANDER/吉尔·桑达",
            "Jimmy Choo/周仰杰",
            "Kate Spade/凯特·丝蓓",
            "KENZO/高田贤三",
            "Lanvin/朗雯",
            "LOEWE/罗意威",
            "longchamp/珑骧",
            "Louis Vuitton/LV/路易·威登",
            "Louis Quatorze/瑞克朵丝",
            "Luella/卢埃拉",
            "Mawi",
            "MCM",
            "Marc Jacobs/马克·雅可布",
            "Marni",
            "Miu Miu/缪缪",
            "Moschino/莫斯奇诺",
            "Mulberry/迈宝瑞",
            "Philipp-Plein",
            "Balmain/巴尔曼",
            "Pierre Hardy",
            "Polo Ralph Lauren/拉夫·劳伦",
            "PRADA/普拉达",
            "Proenza Schouler",
            "Rag&Bone/瑞格布恩",
            "Salvatore Ferragamo/SF/菲拉格慕",
            "SergioRossi/塞乔·罗西",
            "Stella McCartney/斯特拉-麦卡托尼",
            "Tod's/托德斯",
            "Tom Ford/汤姆·福特",
            "Tory Burch/汤丽柏琦",
            "TOUS/桃丝熊",
            "Valentino/华伦天奴",
            "Versace/范思哲",
            "Victoria Beckham/维多利亚·贝克汉姆",
            "Vivienne Westwood/维维安·韦斯特伍德",
            "Yves Saint Laurent/YSL/圣罗兰",
            'Christian Louboutin/克里斯提·鲁布托'
        ];
        $list = [];
        foreach($title as $key=>$ti){
            if($key==0){
                $firstword = 'B';
            }else{
                $firstword = substr($ti,0,1);
            }

            $list[$key]=[
                'superior_id'=>'140759',
                'superior_gene'=>'4-140759',
                'type'=>3,
                'state'=>0,
                'title'=>$ti,
                'createtime'=>date('Y-m-d H:i:s',time()),
                'system_id'=>1,
                'label'=>$firstword,
            ];
        }
        try{
            $inser_Data = Db::table('systematics')
                ->insertAll($list);

            var_dump(['insert_shoe'=>$inser_Data]);
        }catch(Exception$e){
            var_dump($e->getMessage());
        }
    }
 //Christian Dior/克里斯汀·迪奥
    public function delect_gst(){
        $data = Db::table('systematics')
            ->where(['title'=>['like','Christian Dior%'],'type'=>3])
            ->select();
        $gene = [];
        $geneid = [];
        foreach($data as $k=>$v){
            $geneid[$k] = $v['superior_gene'].'-'.$v['id'];
            $gene[$k] = $v['superior_gene'];

        }
        $id = Db::table('systematics')
            ->where(['superior_gene'=>['in',$geneid],'title'=>['like','gst']])
           ->field('id')
            ->select();

        $id = array_column($id,'id');
        $data_delect = Db::table('systematics')
            ->where(['id'=>['in',$id]])
            ->delete();
        var_dump($data_delect);exit;

    }
   //piazza手袋
 public function delect_piazza(){
     $data = Db::table('systematics')
         ->where(['title'=>['like','Bottege Veneta%'],'type'=>3])
         ->select();
       $gene = [];
       foreach($data as $k=>$v){
           $gene[$k] = $v['superior_gene'].'-'.$v['id'];
       }

     $use_data = Db::table('systematics')
         ->where(['title'=>['like','piazza%'],'superior_gene'=>['in',$gene]])
         ->select();

     $attr = array_column($use_data,'id');
     $attrt = array_column($use_data,'superior_id');
     $user_data = array_combine($attrt,$attr);
     $datat = Db::table('systematics')
         ->where(['id'=>['in',$user_data]])
         ->delete();

     var_dump($datat);exit;
 }














}